package com.itheima.args;

public class Demo01 {
    //利用可变参数计算n个数的累加和

    public static void main(String[] args) {

        int sum = getSum(1, 2, 3, 4, 5, 6);

        System.out.println(sum);//21
    }

    public static int getSum(int a,int... args)
    {
        int sum=0;
        for (int arg : args) {
            sum+=arg;
        }

        return sum;
    }
}
